package com.woniu.mall.controller;

import com.woniu.common.annotation.LoginUser;
import com.woniu.common.entity.Result;
import com.woniu.mall.service.CouponUserService;
import com.woniu.user.vo.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 1. @description:
 * 2. @author: Lingger
 * 3. @time: 2023/5/23
 */
@RequestMapping("/couponUser")
@RestController
@Api(tags = "优惠券用户端")
public class CouponUserController {

    @Autowired
    private CouponUserService couponUserService;

    @ApiOperation("用户购买红包")
    @GetMapping("/buyRedEnvelope")
    public Result buyRedEnvelope(@LoginUser UserLoginVO UserLoginVO) {

        Boolean flag = couponUserService.buyRedEnvelope(UserLoginVO.getMobile());
        return Result.ok(flag);
    }

    @ApiOperation("用户购买商家代金券")
    @GetMapping("/buyBusinessCoupon/{storeId}")
    public Result buyBusinessCoupon(@PathVariable("storeId") Integer storeId, @LoginUser UserLoginVO UserLoginVO) {

        Boolean flag = couponUserService.buyBusinessCoupon(storeId, UserLoginVO);
        return Result.ok(flag);
    }
}
